

//原生方式实现
// const fs = require('fs');

// fs.readFile('./resource/1.html', (err, data1) => {
//     if(err) throw err;
//     fs.readFile('./resource/2.html', (err, data2) => {
//         if(err) throw err;
//         fs.readFile('./resource/3.html', (err, data3) => {
//             if(err) throw err;
//             console.log(data1.toString() + data2.toString() + data3.toString());
//         });
//     });
// });

//promise
let fs = require('fs/promises');

let p1 = fs.readFile('./resource/1.html');
let p2 = fs.readFile('./resource/2.html');
let p3 = fs.readFile('./resource/3.html');

let result = Promise.all([p1, p2, p3]);

result.then(value => {
    let str = value.map(item => item.toString()).join('')
    console.log(str);
}, reason => {
    console.log(reason);
});







